<template>
  <!-- 导入商品时显示平台上的商品库 -->
  <div>
    <basic-modal 
        :modalOpt="modal" 
        :buttonText="['','关闭']"
        @onMakeSure="onPush"
        @closeModal="closeModal"
        :footer="footer" 
    >
      <template #cusBtn>
      </template>
      <template>
        <batch-operat-btn v-if="editable" :isView="false" :addData="true" @onAddData="onAddData">
          <template #cusBtn> </template>
        </batch-operat-btn>
        <div class="recordBox">
          <a-list-table
            :columns="columns"
            :tableData="listdata"
            :isSelecttion="false"
            :loading="loading"
            :scroll="{ y: null }"
            :pagination="pagination"
            @onTableChange="handleTableChange"
          >
          </a-list-table>
        </div>
      </template>
    </basic-modal>
  </div>
</template>

<script>
import basicModal from '@/views/app/biz/common/basicModal'
import aListTable from '@/views/app/biz/common/aListTable'
import aListInfo from '@/views/app/biz/common/aListInfo'
import batchOperatBtn from '@/views/app/biz/common/batchOperatBtn'

import {
  getStoreByConditions,
  getStoreByConditionsCount,
} from './purchasedgoods'
export default {
  components: {
    basicModal,
    aListTable,
    batchOperatBtn,
    aListInfo
  },
  data() {
    return {
      footer:undefined,
      editable:false,
      loading: false,
      modal: {
        modalVisible: false,
        modalTitle: '下载标准编码',
        modalWidth: '80vw',
        maxHeight:'70vh'
      },
      infoDatas:[

      ],
      columns:[
        { title:'数据有效范围代码', dataIndex:'areaDm', key: 'areaDm', align: 'center'},
        { title:'数据有效范围名称', dataIndex:'areaCT', key: 'areaCT', align: 'center'},
        { title:'上级代码', dataIndex:'parentDm', key: 'parentDm', align: 'center'},
        { title: '状态', dataIndex: 'state', key: 'state', align: 'center' },
        {
          title: '操作',
          dataIndex: 'action', 
          key: 'operation',
          width: 180,
          align: 'center',
          scopedSlots: { customRender: 'action' }
        }
      ],
      sData: {
        purOrderPid: null,
      },
      listdata: [],
      BarCode:'',
      pagination: {
        //分页配置
        current: 1, //当前页码 current
        pageSize: 10, //每页显示条数 pageSize
        total: 1,
        showQuickJumper: true,
        showSizeChanger: true,
        pageSizeOptions: ['1', '5', '10', '100'],
      },
      listKey: 0,
      pid: '',
      zzPid:'',
      sysSeq: 0,
      loadings: false,
    }
  },
  computed: {},
  mounted() {},
  methods: {
    // // 弹出模态框
    showModal(val,record) {
      this.pid = val
      this.record=record
      this.modal.modalVisible = true
      this.modal.modalTitle = '下载标准编码'
      this.sData.purOrderPid= val
      this.getTotal()
      this.getDetailBypid(this.sData)
      
    },
    // 关闭模态详细框
    closeModal() {
      this.modal.modalVisible = false
      this.$emit('close')
    },
    closeModal2() {
      this.modal.modalVisible = false
      this.$emit('ok')
    },
    //
    onAddData() {
      this.$refs.addSellerLicChildModal.addModal(this.pid)
    },

    // 审核
    onPush() {
    },
    // 触发改变页码,筛选,排序时的回调
    handleTableChange(pagination, filters, sorter) {
      this.pagination.current = pagination.current
      this.pagination.pageSize = pagination.pageSize
      this.getDetailBypid(this.sData)
    },
    // 初始化页面时得到总数
    async getTotal() {
      let pages = ''
      pages = await getStoreByConditionsCount(this.sData)
      console.log(pages)
      if (pages && pages.code && pages.code === 'C1') {
        const pagination = { ...this.pagination }
        pagination.total = pages.data
        this.pagination = pagination
        this.pagination.showTotal =  (showTotal) => {return `共 ${showTotal} 条`}
      }
    },
    //得到初始化订单商品list
    async getDetailBypid(params) {
      console.log('请求列表时传入的数据', params)
      this.loading = true
      let listdata = []
      let res = ''
      res = await getStoreByConditions(params, this.pagination)
      this.loading = false
      console.log(res)
      if (res && res.code && res.code === 'C1' && res.data) {
        const resdata = res.data
        this.orgList=res.data
         for (let item of resdata) {
            listdata.push({
               key: item.pid,
               ...item,
               action:['预览','下载']
               }
            )
         }
         this.listdata =listdata
      } else {
        this.listdata = []
      }
    },
  },
}
</script>

<style>
.recordBox {
  width: 100%;
  min-height: 80px;
}
</style>